﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="AssesmentPositionForm.aspx.cs" Inherits="Assesment.Web.Forms.Transaction.AssesmentPositionForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="Server">
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.inputmask.bundle.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.msgBox.v1.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/chosen/chosen.jquery.min.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />
    <style type="text/css">
        table.gridtable
        {
            font-family: verdana,arial,sans-serif;
            font-size: 11px;
            color: #333333;
            border-width: 1px;
            border-color: #666666;
            border-collapse: collapse;
        }
        table.gridtable th
        {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #dedede;
        }
        table.gridtable td
        {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #ffffff;
        }
    </style>
    <script type="text/javascript">

        function BackPage() {
            var page = '<%= ResolveUrl("~/lists/Transaction/AssesmentPositionList.aspx") %>' + '?menuId=' + '<%= base.MenuID %>';
            window.location.href = page;
        }
        $(document).ready(function () {
            $("#btnSave").button({ icons: { primary: "ui-icon-disk"} });
            $("#btnClose").button({ icons: { primary: "ui-icon-close"} });

            $("#btnSave2").button({ icons: { primary: "ui-icon-disk"} });
            $("#btnClose2").button({ icons: { primary: "ui-icon-close"} });


            $('#btnClose').click(function () {
                BackPage();
            });

            $('#btnClose2').click(function () {
                BackPage();
            });

            $('#<%= ddlDepartemen.ClientID %>').chosen({ placeholder_text_single: "-- pilih departemen --" });
            $('#<%= ddlNIK.ClientID %>').chosen({ placeholder_text_single: "-- pilih NIK --" });
            $('#<%= ddlJabatanTujuan.ClientID %>').chosen({ placeholder_text_single: "-- pilih jabatan --" });


            $('#<%= txtTglAssesment.ClientID %>').datepicker({
                numberOfMonths: 1,
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy'
            });




        });
 
    </script>
    <script language="javascript" type="text/javascript">

        $(document).ready(function () {


            // 1. prepare the validation rules and messages.
            var rules = {
                ddlNIK: "required"

            };
            var messages = {
                ddlNIK: "NIK  wajib di isi"

            };


            // 2. Initiate the validator
            var validator = new jQueryValidatorWrapper("body", rules, messages);

            var id = $('#<%= hfID.ClientID %>').val();

            if (id != "") {

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourCustomerFocus', 'tblKeyBehaviourCustomerFocusCheck', 'tblKeyBehaviourCustomerFocusRating', 'CUSTOMER FOCUS', 'tblLevelCustomerFocus');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourIntegrity', 'tblKeyBehaviourIntegrityCheck', 'tblKeyBehaviourIntegrityRating', 'INTEGRITY', 'tblLevelIntegrity');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourTeamWork', 'tblKeyBehaviourTeamWorkCheck', 'tblKeyBehaviourTeamWorkRating', 'TEAM WORK', 'tblLevelTeamWork');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourContinous', 'tblKeyBehaviourContinousCheck', 'tblKeyBehaviourContinousRating', 'CONTINOUS', 'tblLevelContinous');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourWorkExcellence', 'tblKeyBehaviourWorkExcellenceCheck', 'tblKeyBehaviourWorkExcellenceRating', 'WORK EXCELLENCE', 'tblLevelWorkExcellence');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourFinancial', 'tblKeyBehaviourFinancialCheck', 'tblKeyBehaviourFinancialRating', 'FINANCIAL', 'tblLevelFinancial');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourBussines', 'tblKeyBehaviourBussinesCheck', 'tblKeyBehaviourBussinesRating', 'BUILDING', 'tblLevelBussines');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourLeadership', 'tblKeyBehaviourLeadershipCheck', 'tblKeyBehaviourLeadershipRating', 'LEADERSHIP', 'tblLevelLeadership');

                LoadKeyBehaviorEdit(id, 'tblKeyBehaviourResource', 'tblKeyBehaviourResourceCheck', 'tblKeyBehaviourResourceRating', 'RESOURCE', 'tblLevelResource');

            }
            $('#<%= ddlLokasi.ClientID %>').change(function () {
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/PositionLoadHandler.ashx") %>';
                var departmentID = $('#<%= ddlDepartemen.ClientID %> option:selected').val();
                var locationID = $('#<%= ddlLokasi.ClientID %> option:selected').val();
                if (departmentID != "" && locationID != "") {
                    var $ddlJabatanTujuan = $('#<%= ddlJabatanTujuan.ClientID %>')
                    $('#<%= ddlJabatanTujuan.ClientID %>').find('option:not(:first)').remove();
                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + "?method=getpositionbydeptid&departmentID=" + departmentID + "&locationID=" + locationID,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $ddlJabatanTujuan.get(0).options[0] = new Option("-- pilih jabatan --", "");
                            $.each(datas, function (i, data) {
                                $ddlJabatanTujuan.append('<option value="' + data.PositionID + '">' + data.PositionName + '</option>');
                            });
                            $ddlJabatanTujuan.trigger('chosen:updated');
                        },
                        error: function () {
                            alert('Error load jabatan tujuan!');
                        }
                    });
                }
            });

            $('#<%= ddlJabatanTujuan.ClientID %>').change(function () {
                var PositionID = $('#<%= ddlJabatanTujuan.ClientID %> option:selected').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Transaction/AssesmentPositionLoad.ashx") %>';
                var NIK = $('#<%= ddlNIK.ClientID %> option:selected').val();

                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=getbyAssesmentPositionID_NIK&PositionIDAssesment=" + PositionID + "&NIK=" + NIK,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        if (datas.AssesmentPositionID != "") {
                            $.msgBox("NIK dengan Jabatan Assesment tersebut sudah pernah di entry !", null, { title: "Pesan" });
                            var id = datas.AssesmentPositionID;
                            $('#<%= hfID.ClientID %>').val(id);
                            $('#<%= txtTglAssesment.ClientID %>').val(datas.AssesmentDate);

                            RemoverTrTable();
                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourCustomerFocus', 'tblKeyBehaviourCustomerFocusCheck', 'tblKeyBehaviourCustomerFocusRating', 'CUSTOMER FOCUS', 'tblLevelCustomerFocus');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourIntegrity', 'tblKeyBehaviourIntegrityCheck', 'tblKeyBehaviourIntegrityRating', 'INTEGRITY', 'tblLevelIntegrity');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourTeamWork', 'tblKeyBehaviourTeamWorkCheck', 'tblKeyBehaviourTeamWorkRating', 'TEAM WORK', 'tblLevelTeamWork');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourContinous', 'tblKeyBehaviourContinousCheck', 'tblKeyBehaviourContinousRating', 'CONTINOUS', 'tblLevelContinous');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourWorkExcellence', 'tblKeyBehaviourWorkExcellenceCheck', 'tblKeyBehaviourWorkExcellenceRating', 'WORK EXCELLENCE', 'tblLevelWorkExcellence');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourFinancial', 'tblKeyBehaviourFinancialCheck', 'tblKeyBehaviourFinancialRating', 'FINANCIAL', 'tblLevelFinancial');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourBussines', 'tblKeyBehaviourBussinesCheck', 'tblKeyBehaviourBussinesRating', 'BUILDING', 'tblLevelBussines');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourLeadership', 'tblKeyBehaviourLeadershipCheck', 'tblKeyBehaviourLeadershipRating', 'LEADERSHIP', 'tblLevelLeadership');

                            LoadKeyBehaviorEdit(id, 'tblKeyBehaviourResource', 'tblKeyBehaviourResourceCheck', 'tblKeyBehaviourResourceRating', 'RESOURCE', 'tblLevelResource');

                        }
                        else {

                            RemoverTrTable();

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourCustomerFocus', 'tblKeyBehaviourCustomerFocusCheck', 'tblKeyBehaviourCustomerFocusRating', 'CUSTOMER FOCUS', 'tblLevelCustomerFocus');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourIntegrity', 'tblKeyBehaviourIntegrityCheck', 'tblKeyBehaviourIntegrityRating', 'INTEGRITY', 'tblLevelIntegrity');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourTeamWork', 'tblKeyBehaviourTeamWorkCheck', 'tblKeyBehaviourTeamWorkRating', 'TEAM WORK', 'tblLevelTeamWork');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourContinous', 'tblKeyBehaviourContinousCheck', 'tblKeyBehaviourContinousRating', 'CONTINOUS', 'tblLevelContinous');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourWorkExcellence', 'tblKeyBehaviourWorkExcellenceCheck', 'tblKeyBehaviourWorkExcellenceRating', 'WORK EXCELLENCE', 'tblLevelWorkExcellence');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourFinancial', 'tblKeyBehaviourFinancialCheck', 'tblKeyBehaviourFinancialRating', 'FINANCIAL', 'tblLevelFinancial');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourBussines', 'tblKeyBehaviourBussinesCheck', 'tblKeyBehaviourBussinesRating', 'BUILDING', 'tblLevelBussines');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourLeadership', 'tblKeyBehaviourLeadershipCheck', 'tblKeyBehaviourLeadershipRating', 'LEADERSHIP', 'tblLevelLeadership');

                            LoadKeyBehavior(PositionID, 'tblKeyBehaviourResource', 'tblKeyBehaviourResourceCheck', 'tblKeyBehaviourResourceRating', 'RESOURCE', 'tblLevelResource');

                        }
                    },
                    error: function () {
                        alert('Error load Jabatan assesment current!');
                    }
                });


            });

            $('#<%= ddlNIK.ClientID %>').change(function () {
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/KaryawanLoad.ashx") %>';
                var NIK = $('#<%= ddlNIK.ClientID %> option:selected').val();
                if (NIK != "") {
                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + "?method=getbyid&NIK=" + NIK,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $('#<%= txtNama.ClientID %>').val(datas.NamaKaryawan);
                            $('#<%= txtJabatan.ClientID %>').val(datas.Jabatan);
                            $('#<%= txtLokasiKerja.ClientID %>').val(datas.Lokasi);
                        },
                        error: function () {
                            alert('Error load data NIK!');
                        }
                    });
                }
            });

            $("#btnSave").click(function () {
                SaveData();
            });

            $("#btnSave2").click(function () {
                SaveData();
            });

        });

        function SaveData() {
            var NIK = $("#<%=ddlNIK.ClientID %>").val();
            if (NIK == "") {
                $.msgBox("NIK wajib di pilih !", null, { title: "Pesan" });
                return;
            }

            var tgl = $("#<%=txtTglAssesment.ClientID %>").val();
            if (tgl == "") {
                $.msgBox("Tgl Assesment wajib di isi !", null, { title: "Pesan" });
                return;
            }

            var departemen = $("#<%=ddlDepartemen.ClientID %>").val();
            if (departemen == "") {
                $.msgBox("Departemen wajib di pilih !", null, { title: "Pesan" });
                return;
            }

            var lokasi = $("#<%=ddlLokasi.ClientID %>").val();
            if (lokasi == "") {
                $.msgBox("Lokasi wajib di pilih !", null, { title: "Pesan" });
                return;
            }

            var jabatan = $("#<%=ddlJabatanTujuan.ClientID %>").val();
            if (jabatan == "") {
                $.msgBox("Jabatan Tujuan wajib di pilih !", null, { title: "Pesan" });
                return;
            }

            ///GROUP CUSTOMER FOCUS

            var RatingCustomerFocus = "";
            $('#tblKeyBehaviourCustomerFocusRating tr').each(function () {
                var row = $(this);
                //var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if //(row.find('input[type="checkbox"]').is(':checked'))
                //&& 
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating Customer Focus !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingCustomerFocus = isi;
                }

            });

            var statusCheckListCustomerFocus = "";
            var KeyBehaviourDetailIDCustomerFocus = "";
            $('#tblKeyBehaviourCustomerFocusCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListCustomerFocus += "1" + "|";
                    KeyBehaviourDetailIDCustomerFocus += idCheckBox + "|";
                }
                else {
                    statusCheckListCustomerFocus += "0" + "|";
                    KeyBehaviourDetailIDCustomerFocus += idCheckBox + "|";
                }

            });

            //END GROUP CUSTOMER FOCUS

            ///GROUP INTEGRITY

            var RatingIntegrity = "";
            $('#tblKeyBehaviourIntegrityRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating Integrity !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingIntegrity = isi;
                }

            });

            var statusCheckListIntegrity = "";
            var KeyBehaviourDetailIDIntegrity = "";
            $('#tblKeyBehaviourIntegrityCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListIntegrity += "1" + "|";
                    KeyBehaviourDetailIDIntegrity += idCheckBox + "|";
                }
                else {
                    statusCheckListIntegrity += "0" + "|";
                    KeyBehaviourDetailIDIntegrity += idCheckBox + "|";
                }

            });

            //END GROUP INTEGRITY

            ///GROUP TEAM WORK

            var RatingTeamWork = "";
            $('#tblKeyBehaviourTeamWorkRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating Integrity !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingTeamWork = isi;
                }

            });

            var statusCheckListTeamWork = "";
            var KeyBehaviourDetailIDTeamWork = "";
            $('#tblKeyBehaviourTeamWorkCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListTeamWork += "1" + "|";
                    KeyBehaviourDetailIDTeamWork += idCheckBox + "|";
                }
                else {
                    statusCheckListTeamWork += "0" + "|";
                    KeyBehaviourDetailIDTeamWork += idCheckBox + "|";
                }

            });

            //END GROUP TEAM WORK

            ///GROUP CONTINOUS LEARNING

            var RatingContinous = "";
            $('#tblKeyBehaviourContinousRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating Integrity !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingContinous = isi;
                }

            });

            var statusCheckListContinous = "";
            var KeyBehaviourDetailIDContinous = "";
            $('#tblKeyBehaviourContinousCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListContinous += "1" + "|";
                    KeyBehaviourDetailIDContinous += idCheckBox + "|";
                }
                else {
                    statusCheckListContinous += "0" + "|";
                    KeyBehaviourDetailIDContinous += idCheckBox + "|";
                }

            });

            //END GROUP CONTINOUS LEARNING

            ///GROUP WORK EXCELLENCE

            var RatingWorkExcellence = "";
            $('#tblKeyBehaviourWorkExcellenceRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating work excellence !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingWorkExcellence = isi;
                }

            });

            var statusCheckListWorkExcellence = "";
            var KeyBehaviourDetailIDWorkExcellence = "";
            $('#tblKeyBehaviourWorkExcellenceCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListWorkExcellence += "1" + "|";
                    KeyBehaviourDetailIDWorkExcellence += idCheckBox + "|";
                }
                else {
                    statusCheckListWorkExcellence += "0" + "|";
                    KeyBehaviourDetailIDWorkExcellence += idCheckBox + "|";
                }

            });

            //END GROUP WORK EXCELLENCE


            ///GROUP FINANCIAL ACCUMENT

            var RatingFinancial = "";
            $('#tblKeyBehaviourFinancialRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating financial accument !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingFinancial = isi;
                }

            });

            var statusCheckListFinancial = "";
            var KeyBehaviourDetailIDFinancial = "";
            $('#tblKeyBehaviourFinancialCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListFinancial += "1" + "|";
                    KeyBehaviourDetailIDFinancial += idCheckBox + "|";
                }
                else {
                    statusCheckListFinancial += "0" + "|";
                    KeyBehaviourDetailIDFinancial += idCheckBox + "|";
                }

            });

            //END GROUP  FINANCIAL ACCUMENT


            ///GROUP BUSSINES PARTNERSHIP

            var RatingBussines = "";
            $('#tblKeyBehaviourBussinesRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating bussines partnership !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingBussines = isi;
                }

            });

            var statusCheckListBussines = "";
            var KeyBehaviourDetailIDBussines = "";
            $('#tblKeyBehaviourBussinesCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListBussines += "1" + "|";
                    KeyBehaviourDetailIDBussines += idCheckBox + "|";
                }
                else {
                    statusCheckListBussines += "0" + "|";
                    KeyBehaviourDetailIDBussines += idCheckBox + "|";
                }

            });

            //END GROUP  FINANCIAL ACCUMENT

            ///GROUP LEADERSHIP

            var RatingLeadership = "";
            $('#tblKeyBehaviourLeadershipRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating leadership !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingLeadership = isi;
                }

            });

            var statusCheckListLeadership = "";
            var KeyBehaviourDetailIDLeadership = "";
            $('#tblKeyBehaviourLeadershipCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListLeadership += "1" + "|";
                    KeyBehaviourDetailIDLeadership += idCheckBox + "|";
                }
                else {
                    statusCheckListLeadership += "0" + "|";
                    KeyBehaviourDetailIDLeadership += idCheckBox + "|";
                }

            });

            //END GROUP LEADERSHIP

            ///GROUP RESOURCE MANAGEMENT

            var RatingResource = "";
            $('#tblKeyBehaviourResourceRating tr').each(function () {
                var row = $(this);

                if
                    (row.find('input[type="text"]').val().length <= 0) {
                    //alert('Isi rating resource management !');
                }
                else {
                    var isi = row.find('input[type="text"]').val();
                    RatingResource = isi;
                }

            });

            var statusCheckListResource = "";
            var KeyBehaviourDetailIDResource = "";
            $('#tblKeyBehaviourResourceCheck tr').each(function () {
                var row = $(this);
                var idCheckBox = row.find('input[type="checkbox"]').attr('id');
                if (row.find('input[type="checkbox"]').is(':checked')) {
                    statusCheckListResource += "1" + "|";
                    KeyBehaviourDetailIDResource += idCheckBox + "|";
                }
                else {
                    statusCheckListResource += "0" + "|";
                    KeyBehaviourDetailIDResource += idCheckBox + "|";
                }

            });

            //                //END GROUP RESOURCE MANAGEMENT

            var NIK = $('#<%= ddlNIK.ClientID %> option:selected').val();
            var departemen = $('#<%= ddlDepartemen.ClientID %> option:selected').val();
            var jabatan = $('#<%= ddlJabatanTujuan.ClientID %> option:selected').val();
            var id = $('#<%= hfID.ClientID %>').val();
            var tglAsessment = $('#<%= txtTglAssesment.ClientID %>').val();
            var fit = $('#<%= ddlTotalFit.ClientID %> option:selected').val();
            var individual = $('#<%= txtPenilaianIndividu.ClientID %>').val();
            var leadership = $('#<%= ddlLeadership.ClientID %> option:selected').val();
            var personality = $('#<%= ddlPersonality.ClientID %> option:selected').val();

            var objAssesmentPosition = new Object();
            objAssesmentPosition.AssesmentPositionID = id;
            objAssesmentPosition.NIK = encodeURIComponent(NIK);
            objAssesmentPosition.PositionIDAssesment = encodeURIComponent(jabatan);
            objAssesmentPosition.DepartmentIDAssesment = encodeURIComponent(departemen);
            objAssesmentPosition.AssesmentDate = encodeURIComponent(tglAsessment);
            objAssesmentPosition.TotalFitID = encodeURIComponent(fit);
            objAssesmentPosition.PersonalDescription = encodeURIComponent(individual);
            objAssesmentPosition.PersonalityID = encodeURIComponent(leadership);
            objAssesmentPosition.LeadershipID = encodeURIComponent(personality);



            ///GROUP CUSTOMER FOCUS
            objAssesmentPosition.RatingCustomerFocus = encodeURIComponent(RatingCustomerFocus);
            objAssesmentPosition.StatusCheckListCustomerFocus = encodeURIComponent(statusCheckListCustomerFocus);
            objAssesmentPosition.KeyBehaviourDetailIDCustomerFocus = encodeURIComponent(KeyBehaviourDetailIDCustomerFocus);
            //END GROUP CUSTOMER FOCUS

            ///GROUP INTEGRITY
            objAssesmentPosition.RatingIntegrity = encodeURIComponent(RatingIntegrity);
            objAssesmentPosition.StatusCheckListIntegrity = encodeURIComponent(statusCheckListIntegrity);
            objAssesmentPosition.KeyBehaviourDetailIDIntegrity = encodeURIComponent(KeyBehaviourDetailIDIntegrity);
            //END GROUP INTEGRITY

            ///GROUP TEAM WORK
            objAssesmentPosition.RatingTeamWork = encodeURIComponent(RatingTeamWork);
            objAssesmentPosition.StatusCheckListTeamWork = encodeURIComponent(statusCheckListTeamWork);
            objAssesmentPosition.KeyBehaviourDetailIDTeamWork = encodeURIComponent(KeyBehaviourDetailIDTeamWork);
            //END GROUP TEAM WORK

            ///GROUP CONTINOUS LEARNING
            objAssesmentPosition.RatingContinous = encodeURIComponent(RatingContinous);
            objAssesmentPosition.StatusCheckListContinous = encodeURIComponent(statusCheckListContinous);
            objAssesmentPosition.KeyBehaviourDetailIDContinous = encodeURIComponent(KeyBehaviourDetailIDContinous);
            //END GROUP CONTINOUS LEARNING

            ///GROUP WORK EXCELLENCE
            objAssesmentPosition.RatingWorkExcellence = encodeURIComponent(RatingWorkExcellence);
            objAssesmentPosition.StatusCheckListWorkExcellence = encodeURIComponent(statusCheckListWorkExcellence);
            objAssesmentPosition.KeyBehaviourDetailIDWorkExcellence = encodeURIComponent(KeyBehaviourDetailIDWorkExcellence);
            //END GROUP WORK EXCELLENCE

            ///GROUP FINANCIAL ACCUMENT
            objAssesmentPosition.RatingFinancial = encodeURIComponent(RatingFinancial);
            objAssesmentPosition.StatusCheckListFinancial = encodeURIComponent(statusCheckListFinancial);
            objAssesmentPosition.KeyBehaviourDetailIDFinancial = encodeURIComponent(KeyBehaviourDetailIDFinancial);
            //END GROUP FINANCIAL ACCUMENT

            ///GROUP BUSSINES PARTNERSHIP
            objAssesmentPosition.RatingBussines = encodeURIComponent(RatingBussines);
            objAssesmentPosition.StatusCheckListBussines = encodeURIComponent(statusCheckListBussines);
            objAssesmentPosition.KeyBehaviourDetailIDBussines = encodeURIComponent(KeyBehaviourDetailIDBussines);
            //END GROUP BUSSINES PARTNERSHIP

            ///GROUP LEADERSHIP
            objAssesmentPosition.RatingLeadership = encodeURIComponent(RatingLeadership);
            objAssesmentPosition.StatusCheckListLeadership = encodeURIComponent(statusCheckListLeadership);
            objAssesmentPosition.KeyBehaviourDetailIDLeadership = encodeURIComponent(KeyBehaviourDetailIDLeadership);
            //END GROUP LEADERSHIP

            ///GROUP RESOURCE MANAGEMENT
            objAssesmentPosition.RatingResource = encodeURIComponent(RatingResource);
            objAssesmentPosition.StatusCheckListResource = encodeURIComponent(statusCheckListResource);
            objAssesmentPosition.KeyBehaviourDetailIDResource = encodeURIComponent(KeyBehaviourDetailIDResource);
            //END GROUP RESOURCE MANAGEMENT

            jsonData = JSON.stringify(objAssesmentPosition);

            var handlerUrl = '<%= ResolveUrl("~/ajaxhandler/Transaction/AssesmentPositionHandler.ashx") %>';

            //                if (id == 0)
            //                    CallAjax(handlerUrl, "?method=insert", jsonData);
            //                else {
            //                    CallAjax(handlerUrl, "?method=update", jsonData);
            //                }

            if (id == 0) {

                $.ajax({
                    type: 'POST',
                    url: handlerUrl + '?method=insert',
                    contentType: 'application/json',
                    dataType: 'json',
                    data: jsonData,
                    success: function (data) {
                        if (data.IsSuccess) {
                            //alert(data.Message);

                            $.msgBox(data.Message, null, { title: "Pesan" });

                            var page = '<%= ResolveUrl("~/lists/Transaction/AssesmentPositionList.aspx") %>' + '?menuId=' + '<%= base.MenuID %>';
                            window.location.href = page;

                        }
                        else {
                            //alert(data.Message);

                            $.msgBox(data.Message, null, { title: "Pesan" });
                        }
                    },
                    error: function (response) {
                        var r = JSON.parse(response.responseText);
                        alert("Error Message: " + r.Message);
                    }
                });

            }
            else {

                $.ajax({
                    type: 'POST',
                    url: handlerUrl + '?method=update',
                    contentType: 'application/json',
                    dataType: 'json',
                    data: jsonData,
                    success: function (data) {
                        if (data.IsSuccess) {

                            $.msgBox(data.Message, null, { title: "Pesan" });
                            var page = '<%= ResolveUrl("~/lists/Transaction/AssesmentPositionList.aspx") %>' + '?menuId=' + '<%= base.MenuID %>';
                            window.location.href = page;

                        }
                        else {

                            $.msgBox(data.Message, null, { title: "Pesan" });
                        }
                    },
                    error: function (response) {
                        var r = JSON.parse(response.responseText);
                        alert("Error Message: " + r.Message);
                    }
                });
            }
        }
        function LoadKeyBehavior(PositionID, tableDetail, tableCheck, tableRating, CompetencyDesc, tableLevel) {

            //var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/ManagerialKeyBehaviourDetailLoad.ashx") %>';
            //var PositionID = $('#<%= ddlJabatanTujuan.ClientID %> option:selected').val();
            var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/KeyBehaviourDetailLoad.ashx") %>';

            if (PositionID != "") {
                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=getbyPositionID_CompetencyDesc&PositionID=" + PositionID + "&CompetencyDesc=" + CompetencyDesc,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        var html = "";
                        var No = 1;
                        var Level = "";
                        $.each(datas, function (i, data) {

                            //html = "<tr><td>" + No + ".</td><td>" + data.KeyBehaviourDetail.KeyBehaviourName + "</td></tr>";
                            html = "<tr><td>" + No + ".</td><td>" + data.KeyBehaviourName + "</td></tr>";
                            $("#" + tableDetail).append(html)

                            html = "<tr><td>" + "<input type='checkbox' id='" + data.KeyBehaviourDetailID + "' />" + "</td></tr>";
                            $("#" + tableCheck).append(html)

                            Level = data.LevelCompetency.Level;


                            No++;
                        });

                        if (datas != "") {
                            html = "<tr><td>" + "<input type='text' id='txtRating' />" + "</td></tr>";
                            $("#" + tableRating).append(html)

                            html = "<tr><td>" + Level + "</td></tr>";
                            $("#" + tableLevel).append(html)
                        }

                    },
                    error: function () {
                        alert('Error load generete keybehaviour!');
                    }
                });
            }

        }


        function LoadKeyBehaviorEdit(AssesmentPositionID, tableDetail, tableCheck, tableRating, CompetencyDesc, tableLevel) {

            var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Transaction/AssesmentPositionDetailLoad.ashx") %>';
            //var PositionID = $('#<%= ddlJabatanTujuan.ClientID %> option:selected').val();
            if (AssesmentPositionID != "") {
                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=getbyAssesmentPositionID_CompetencyDesc&AssesmentPositionID=" + AssesmentPositionID + "&CompetencyDesc=" + CompetencyDesc,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        var html = "";
                        var No = 1;
                        var rating = "";
                        var Level = "";
                        $.each(datas, function (i, data) {

                            html = "<tr><td>" + No + ".</td><td>" + data.KeyBehaviourDetail.KeyBehaviourName + "</td></tr>";

                            $("#" + tableDetail).append(html)

                            if (data.StatusKeyBehaviour == true) {
                                html = "<tr><td>" + "<input checked='checked' type='checkbox' id='" + data.KeyBehaviourDetailID + "' />" + "</td></tr>";
                            }
                            else {
                                html = "<tr><td>" + "<input  type='checkbox' id='" + data.KeyBehaviourDetailID + "' />" + "</td></tr>";
                            }
                            $("#" + tableCheck).append(html)


                            rating = data.Rating;
                            Level = data.KeyBehaviourDetail.LevelCompetency.Level;
                            //alert(data.KeyBehaviourDetail.LevelCompetency.Level);
                            No++;
                        });

                        if (datas != "") {
                            html = "<tr><td>" + "<input value='" + rating + "' type='text' id='txtRating' />" + "</td></tr>";
                            $("#" + tableRating).append(html)

                            html = "<tr><td>" + Level + "</td></tr>";
                            $("#" + tableLevel).append(html)
                        }

                    },
                    error: function () {
                        alert('Error load generete keybehaviour!');
                    }
                });
            }

        }

        function RemoverTrTable() {
            //$("#yourtableid tr").remove();

            $("#tblKeyBehaviourCustomerFocus tr").remove();
            $("#tblLevelCustomerFocus tr").remove();
            $("#tblKeyBehaviourCustomerFocusCheck tr").remove();
            $("#tblKeyBehaviourCustomerFocusRating tr").remove();

            $("#tblKeyBehaviourIntegrity tr").remove();
            $("#tblLevelIntegrity tr").remove();
            $("#tblKeyBehaviourIntegrityCheck tr").remove();
            $("#tblKeyBehaviourIntegrityRating tr").remove();

            $("#tblKeyBehaviourTeamWork tr").remove();
            $("#tblLevelTeamWork tr").remove();
            $("#tblKeyBehaviourTeamWorkCheck tr").remove();
            $("#tblKeyBehaviourTeamWorkRating tr").remove();

            $("#tblKeyBehaviourContinous tr").remove();
            $("#tblLevelContinous tr").remove();
            $("#tblKeyBehaviourContinousCheck tr").remove();
            $("#tblKeyBehaviourContinousRating tr").remove();

            $("#tblKeyBehaviourWorkExcellence tr").remove();
            $("#tblLevelWorkExcellence tr").remove();
            $("#tblKeyBehaviourWorkExcellenceCheck tr").remove();
            $("#tblKeyBehaviourWorkExcellenceRating tr").remove();

            $("#tblKeyBehaviourFinancial tr").remove();
            $("#tblLevelFinancial tr").remove();
            $("#tblKeyBehaviourFinancialCheck tr").remove();
            $("#tblKeyBehaviourFinancialRating tr").remove();

            $("#tblKeyBehaviourBussines tr").remove();
            $("#tblLevelBussines tr").remove();
            $("#tblKeyBehaviourBussinesCheck tr").remove();
            $("#tblKeyBehaviourBussinesRating tr").remove();

            $("#tblKeyBehaviourLeadership tr").remove();
            $("#tblLevelLeadership tr").remove();
            $("#tblKeyBehaviourLeadershipCheck tr").remove();
            $("#tblKeyBehaviourLeadershipRating tr").remove();

            $("#tblKeyBehaviourResource tr").remove();
            $("#tblLevelResource tr").remove();
            $("#tblKeyBehaviourResourceCheck tr").remove();
            $("#tblKeyBehaviourResourceRating tr").remove();


        }
    </script>
    <div class="side-content fr">
        <div class="content-module">
            <div class="content-module-heading cf">
                <h3 class="fl">
                    Assesment Jabatan</h3>
                <span class="fr expand-collapse-text">Click to collapse</span> <span class="fr expand-collapse-text initial-expand">
                    Click to expand</span>
            </div>
            <!-- end content-module-heading -->
            <table border="0" style="padding-left: 20px">
                <tr>
                    <td>
                        NIK
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:DropDownList ID="ddlNIK" runat="server" Width="300">
                                    </asp:DropDownList>
                                </td>
                                <td>
                                    &nbsp;&nbsp;Tgl Assesment&nbsp;&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtTglAssesment" runat="server" Width="100"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Nama
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:TextBox ID="txtNama" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;Departemen &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlDepartemen" runat="server" Width="400">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Jabatan Saat ini
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:TextBox ID="txtJabatan" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;Lokasi &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlLokasi" runat="server" Width="300">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Lokasi Kerja
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:TextBox ID="txtLokasiKerja" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;Jabatan Tujuan&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlJabatanTujuan" runat="server" Width="400">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Tgl Join
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:TextBox ID="txtTglJoin" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;Bobot Total Fit&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlTotalFit" runat="server" Width="400">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Masa Kerja
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:TextBox ID="txtMasaKerja" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;Tipe Kepribadian&nbsp;&nbsp;
                                </td>
                                <td>
                                    :
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlPersonality" runat="server" Width="400">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        Tipe Kepemimpinan
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlLeadership" runat="server" Width="300">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Penilaian Individu
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtPenilaianIndividu" ReadOnly="false" runat="server" TextMode="MultiLine"
                            Width="800" Rows="2"></asp:TextBox>
                        
                    </td>
                </tr>
            </table>
            <br />
            <br />
            <table class="gridtable" style="padding-left: 20px;" id="tbl1" border="1" cellpadding="0"
                cellspacing="0" width="1000px">
                <tr>
                    <td colspan="5">
                        <div style="text-align: right; padding-top: 10px;">
                            <button id="btnSave2" type="button">
                                Save</button>
                            <button id="btnClose2" type="button">
                                Back</button>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th align="center" style="width: 200px;">
                        KOMPETENSI
                    </th>
                    <th align="center" style="width: 50px;">
                        LEVEL
                    </th>
                    <th align="center">
                        KEY BEHAVIOUR
                    </th>
                    <th align="center" style="width: 100px;">
                        CHECK LIST
                    </th>
                    <th align="center" style="width: 100px;">
                        RATING
                    </th>
                </tr>
                <tr>
                    <td>
                        CUSTOMER FOCUS
                    </td>
                    <td>
                        <table id="tblLevelCustomerFocus">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourCustomerFocus">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourCustomerFocusCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourCustomerFocusRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        INTEGRITY
                    </td>
                    <td>
                        <table id="tblLevelIntegrity">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourIntegrity">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourIntegrityCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourIntegrityRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        TEAM WORK
                    </td>
                    <td>
                        <table id="tblLevelTeamWork">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourTeamWork">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourTeamWorkCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourTeamWorkRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        CONTINOUS LEARNING
                    </td>
                    <td>
                        <table id="tblLevelContinous">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourContinous">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourContinousCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourContinousRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        WORK EXCELLENCE
                    </td>
                    <td>
                        <table id="tblLevelWorkExcellence">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourWorkExcellence">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourWorkExcellenceCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourWorkExcellenceRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        B. FINANCIAL ACCUMENT
                    </td>
                    <td>
                        <table id="tblLevelFinancial">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourFinancial">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourFinancialCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourFinancialRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        B. BUSSINES PARTNERSHIP
                    </td>
                    <td>
                        <table id="tblLevelBussines">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourBussines">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourBussinesCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourBussinesRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        LEADERSHIP
                    </td>
                    <td>
                        <table id="tblLevelLeadership">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourLeadership">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourLeadershipCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourLeadershipRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        RESOURCE MANAGEMENT
                    </td>
                    <td>
                        <table id="tblLevelResource">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourResource">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourResourceCheck">
                        </table>
                    </td>
                    <td>
                        <table id="tblKeyBehaviourResourceRating">
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <div style="text-align: right; padding-top: 10px;">
                            <button id="btnSave" type="button">
                                Save</button>
                            <button id="btnClose" type="button">
                                Back</button>
                        </div>
                    </td>
                </tr>
                <asp:HiddenField ID="hfID" runat="server" />
            </table>
            <!-- end content-module-main -->
        </div>
    </div>
</asp:Content>
